#!/bin/bash

# 创建.pip目录并配置pip使用阿里云镜像源
mkdir -p ~/.pip
echo "[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com" > ~/.pip/pip.conf

# 安装Python虚拟环境管理器
apt update && apt install -y python3-venv

# 判断当前目录下是否已存在.yolov8_venv
if [ ! -d ".yolov8_venv" ]; then
    # 创建并激活yolov8的Python虚拟环境
    python3 -m venv .yolov8_venv
    source .yolov8_venv/bin/activate

    # 在虚拟环境中安装所需的包
    pip install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu118
    pip install openvino==2024.0.0
    pip install nncf
    pip install ultralytics==8.0.170
    pip install opencv-python-headless

    # 退出虚拟环境
    deactivate
else
    echo ".yolov8_venv already exists, skipping virtual environment creation."
fi

cp files/Arial.ttf /root/.config/Ultralytics/

echo "Yolov8 environment setup is complete."
